<template>

    <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="标题" prop="title" :error="errors.title">
            <el-input v-model="form.title" clearable></el-input>
        </el-form-item>
        <el-form-item label="描述" prop="description" :error="errors.description">
            <el-input type="textarea" v-model="form.description" clearable></el-input>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="onSubmit">完成</el-button>
        </el-form-item>
    </el-form>
</template>

<script>
    export default {
        props: {careerId: Number, errors: Object}, data() {
            return {
                form: {
                    title: null,
                    description: null,
                }
            }
        }, methods: {
            onSubmit() {
                this.$emit('complete', this.form);
            }, getCareer() {
                axios.get('careers/' + this.careerId).then((response) => {
                    this.form.title = response.data.data.title;
                    this.form.description = response.data.data.description;
                })
            }
        }, created() {
            if (this.careerId) {
                this.getCareer();
            }
        }
    }
</script>